package com.demo.datastructure.reorder.selectorSort;

/**
 * @description:
 * @author: ljr
 * @time: 2021/5/7 21:30
 */
public class MySelectorSort2 {


    public static void selectorSort(int[] args, int n){
      for(int c = 0; c < n-1; c++){
          for(int i = n-2; i >= c ; i--){
              if(args[i+1] < args[i]){
                  int val = args[i+1];
                  args[i+1] = args[i];
                  args[i] = val;
              }
          }
      }
    }

    public static void main(String[] args) {
        int[] nums = new int[]{4,5,6,3,2,1};
        MySelectorSort2.selectorSort(nums,nums.length);
        for(int num : nums){
            System.out.println(num);
        }
    }
}
